package com.itbird.eventbus;

import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.itbird.eventbus.core.EventBus;

/**
 * Created by itbird on 2022/9/19
 */
public class SecondActivity extends AppCompatActivity {
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = findViewById(R.id.textview);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
                    @Override
                    public void run() {
                        //这里用于测试，子线程是否可以如预期，切换为主线程助兴
                        EventBus.getIntance().postEvent(new EventMsg("我是secondactivity，通过itbirdeventbus传递过来的消息"));
                    }
                });
                finish();
            }
        });
    }
}
